package high.concurrent.service;

import high.concurrent.model.CouponRecordDO;
import high.concurrent.model.TasklMessage;
import high.concurrent.request.LockCouponRecordRequest;
import high.concurrent.utils.JsonData;

import java.util.List;

/**
 * 领券表service
 */
public interface CouponRecordService {

    /**
     * 根据优惠券id 和 用户id查询该用户领取几张该优惠券
     * @param couponId 优惠券id
     * @param userId  用户id
     * @return
     */
    List<CouponRecordDO> searchCouponRecordByUser(Long couponId, Long userId);

    /**
     * 插入领券表
     * @param couponRecordDO
     * @return
     */
    int insertCouponRecord(CouponRecordDO couponRecordDO);

    /**
     * 查询个人信息
     * @param page   当前页码
     * @param size   每页记录数
     * @return
     */
    JsonData selectPersonCouponRecord(Integer page, Integer size);

    /**
     * 领券信息详情
     * @param couponRrecordId   领券表主键id
     * @return
     */
    JsonData getCouponRecordDetail(Long couponRrecordId);

    /**
     * 下单锁定优惠券
     * @param lockCouponRecordRequest
     * @return
     */
    JsonData lockCouponRecord(LockCouponRecordRequest lockCouponRecordRequest);

    /**
     * 测试死信队列
     * @return
     */
    void dealQueueTest();

    /**
     * 校验优惠券是否需要回退
     * @param couponRecordMessage
     * @return
     */
    boolean checkCouponRecordTask(TasklMessage couponRecordMessage);
}
